package com.zyplayer.dubbo.config;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

//@Configuration
public class ZookeeperConf {
	
	@Value("${zookeeper.url}")
	private String zookeeperUrl;
	
	@Bean
	public CuratorFramework getCuratorFramework() {
		RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
		CuratorFramework client = CuratorFrameworkFactory.newClient(zookeeperUrl, retryPolicy);
		client.start();
		return client;
	}
}
